package views;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JComboBox;





public class SaveView extends Frame implements ActionListener{
  
	  public static void main(String[] args) {
			
			SaveView v = new SaveView();
		}

  Label la_place = new Label();
  Label la_name = new Label();
  Label la_datatyp = new Label();
  
  Button btn_save=new Button ();
  Button btn_cancel=new Button ();
  Button btn_browse = new Button();
  
  TextField tf_place = new TextField();
  TextField tf_name = new TextField();

  JComboBox combo2 = new JComboBox();
  
 
  
  private SaveView view = null;
	
	public SaveView() {
	
	view = ( new SaveView("Speichern") );
	
	getView().setLayout(null);
	
 
	//Label Speicherort
	getView().getLa_place().setBounds( 30, 50, 80, 20);
	getView().getLa_place().setText("Speicherort:");
	getView().add( getView().getLa_place());
  
  //Label Dateiname
  getView().getLa_name().setBounds( 30, 80, 80, 20);
  getView().getLa_name().setText("Dateiname:");
  getView().add( getView().getLa_name());
  
  //Label Dateityp
  getView().getLa_datatyp().setBounds( 30, 110, 80, 20);
  getView().getLa_datatyp().setText("Dateityp:");  
  getView().add( getView().getLa_datatyp());
	
  //Textfeld Speicherort
  getView().getTf_place().setBounds( 110, 50, 190, 20);
  getView().getTf_place().setText("");
  getView().add( getView().getTf_place());
  
  //Textfeld Dateiname
  getView().getTf_name().setBounds( 110, 80, 265, 20);
  getView().getTf_name().setText("");
  getView().add( getView().getTf_name());
  
  
  //Button Datei speichern
  getView().getBtn_save().setBounds(170, 190, 100, 25);
  getView().getBtn_save().setLabel("Datei speichern");
  getView().add( getView().getBtn_save() );
  
  //Button Abbrechen
  getView().getBtn_cancel().setBounds( 275, 190, 100, 25);
  getView().getBtn_cancel().setLabel("Abbrechen");
  getView().add( getView().getBtn_cancel() );
  
  //Button Browse
  getView().getBtn_browse().setBounds( 315, 50, 60, 20);
  getView().getBtn_browse().setLabel("Browse...");
  getView().add( getView().getBtn_browse() );
  
  //Dropdown
  combo2.setEditable( true );
  combo2.setSelectedItem( "Eintrag" );
  combo2.setMaximumRowCount( 4 );
    
  getView().getBtn_cancel().addActionListener(this);
  getView().getBtn_save().addActionListener(this);
  getView().getBtn_browse().addActionListener(this);		
	
  getView().setSize(400, 250 );
  getView().setVisible(true);
	}
	
	public SaveView getView() {
		return view;
	}

	public void setView(SaveView view) {
		this.view = view;
	}
  
  public SaveView(String Title) {
		super(Title);
  addWindowListener(new WindowAdapter(){
  public void windowClosing(WindowEvent we){
  dispose();
  }
  });
  }
  
  public void MouseClickedCa(ActionEvent e) {
	  getView().dispose();
  
  	}
  public void MouseClickedCr(ActionEvent e) {
		//create a document
	}
  
  public void MouseClickedBr(ActionEvent e) {
		//browse storage location
	}
  
  @Override
	public void actionPerformed(ActionEvent e) {
		if(e.getSource() == getView().getBtn_cancel()){
			MouseClickedCa(e);
		}
		if(e.getSource() == getView().getBtn_save()){
			getView().MouseClickedCr(e);
			}
		if(e.getSource() == getView().getBtn_browse()){
			getView().MouseClickedBr(e);
		}
  }
		
		public Label getLa_place() {
			return la_place;
		}

		public void setLa_place(Label la_place) {
			this.la_place = la_place;
		}

		public Label getLa_name() {
			return la_name;
		}

		public void setLa_name(Label la_name) {
			this.la_name = la_name;
		}
		
		public Label getLa_datatyp() {
			return la_datatyp;
		}

		public void setLa_datatyp(Label la_datatyp) {
			this.la_datatyp = la_datatyp;
		}
		
		public TextField getTf_place() {
			return tf_place;
		}
		
		public void setTf_place(TextField tf_place){
			this.tf_place = tf_place;
		}
			
		public TextField getTf_name(){
			return tf_name;
		}
		
		public void setTf_name(TextField tf_name){
			this.tf_name = tf_name;
		}
		
		public void setBtn_save(Button btn_save) {
			this.btn_save = btn_save;
		}
		
		public Button getBtn_save() {
			return btn_save;
		}
			
		public void setBtn_cancel(Button btn_cancel) {
			this.btn_cancel = btn_cancel;
		}

		public Button getBtn_cancel() {
			return btn_cancel;
		}
		
		public void setBtn_browse(Button btn_browse){
			this.btn_browse = btn_browse;
		}
			
		public Button getBtn_browse() {
			return btn_browse;
		}
  }
  

  